﻿namespace CommonLibrary.Models
{
    using BLToolkit.DataAccess;
    using BLToolkit.Mapping;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    [TableName(Owner = "public", Name = "wf_Workflow")]
    public partial class wf_Workflow
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; }
        public Int32 FormInstanceId { get; set; }
        public String Name { get; set; }
        public String Description { get; set; }
        [NonUpdatable]
        public int State { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Dictionary")]
    public partial class wf_Dictionary
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public String Value { get; set; }
        public String SubGroup { get; set; }
        [NonUpdatable]
        public Int32 State { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Field")]
    public partial class wf_Field
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 FormId { get; set; } // integer
        public Int32 ControlId { get; set; } // integer
        public String Name { get; set; } // character varying(50)(50)
        public Boolean Nullable { get; set; } // boolean
        public Boolean Editable { get; set; } // boolean
        public Int32 Source { get; set; } // integer
        [NonUpdatable]
        public Int32 State { get; set; }
        public String Argument { get; set; } // character varying(200)(200)
        public String DefaultValue { get; set; } // text

        // wf_Field_FormId_fkey
        [Association(ThisKey = "FormId", OtherKey = "Id", CanBeNull = false)]
        public wf_Form wf_Form { get; set; }

        // wf_Field_ControlId_fkey
        [Association(ThisKey = "ControlId", OtherKey = "Id", CanBeNull = false)]
        public wf_FieldControl wf_FieldControl { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_FieldInstance")]
    public partial class wf_FieldInstance
    {
        [PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 TemplateFieldId { get; set; }
        public Int32 FormId { get; set; } // integer
        public Int32 ControlId { get; set; } // integer
        public String Name { get; set; } // character varying(50)(50)
        public Boolean Nullable { get; set; } // boolean
        public Boolean Editable { get; set; } // boolean
        public Int32 Source { get; set; } // integer
        [NonUpdatable]
        public Int32 State { get; set; }
        public String Argument { get; set; } // character varying(200)(200)
        public String DefaultValue { get; set; } // text

        // wf_Field_FormId_fkey
        [Association(ThisKey = "FormId", OtherKey = "Id", CanBeNull = false)]
        public wf_FormInstance wf_FormInstance { get; set; }

        // wf_Field_ControlId_fkey
        [Association(ThisKey = "ControlId", OtherKey = "Id", CanBeNull = false)]
        public wf_FieldControl wf_FieldControl { get; set; }

        [Association(ThisKey = "TemplateFieldId", OtherKey = "Id", CanBeNull = false)]
        public wf_Form wf_Form { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_FieldControl")]
    public partial class wf_FieldControl
    {
        [PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public String Name { get; set; } // character varying(50)(50)
        public String Code { get; set; } // character varying(50)(50)

        // wf_Field_ControlId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "ControlId", CanBeNull = true)]
        public IEnumerable<wf_Field> wf_Fields { get; set; }
    }
    [TableName(Owner = "public", Name = "wf_Flow")]

    public partial class wf_Flow
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 FormId { get; set; } // integer
        public String Name { get; set; } // character varying(50)(50)
        public String Description { get; set; }
        [NonUpdatable]
        public int State { get; set; }

        // wf_Flow_FormId_fkey
        [Association(ThisKey = "FormId", OtherKey = "Id", CanBeNull = false)]
        public wf_FormInstance wf_FormInstance { get; set; }

        // wf_Node_FlowId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FlowId", CanBeNull = true)]
        public IEnumerable<wf_Node> wf_Nodes { get; set; }

        // wf_FlowInstance_FlowId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FlowId", CanBeNull = true)]
        public IEnumerable<wf_FlowInstance> wf_FlowInstances { get; set; }

        // wf_NodeInstance_FlowId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FlowId", CanBeNull = true)]
        public IEnumerable<wf_NodeInstance> wf_NodeInstances { get; set; }        
    }

    [TableName(Owner = "public", Name = "wf_FlowInstance")]
    public partial class wf_FlowInstance
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 FlowId { get; set; } // integer
        [Nullable]
        public Int32? FormId { get; set; } // integer
        [Nullable]
        public Int32? ObjectId { get; set; } // integer
        [Nullable]
        public Int32? CreateUserId { get; set; } // integer
        [Nullable]
        public Int32? CreateDeptId { get; set; }
        [NonUpdatable]
        public Int32 State { get; set; } // integer
        [NonUpdatable]
        public DateTime CreationTime { get; set; }
        [NonUpdatable]
        public DateTime UpdatedTime { get; set; }
        public String Description { get; set; }

        // wf_FlowInstance_FlowId_fkey
        [Association(ThisKey = "FlowId", OtherKey = "Id", CanBeNull = false)]
        public wf_Flow wf_Flow { get; set; }

        // wf_FlowInstance_CreateUserId_fkey
        [Association(ThisKey = "CreateUserId", OtherKey = "Id", CanBeNull = true)]
        public sys_User CreateUser { get; set; }

        [Association(ThisKey = "CreateDeptId", OtherKey = "Id", CanBeNull = true)]
        public sys_Org CreateDept { get; set; }

        // wf_NodeInstance_FlowInstanceId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FlowInstanceId", CanBeNull = true)]
        public IEnumerable<wf_NodeInstance> wf_NodeInstances { get; set; }        
    }

    [TableName(Owner = "public", Name = "wf_Form")]
    public partial class wf_Form
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public String Name { get; set; } // character varying(50)(50)
        [NonUpdatable]
        public int State { get; set; }
        [NonUpdatable]
        public int Version { get; set; }

        // wf_Field_FormId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FormId", CanBeNull = true)]
        public IEnumerable<wf_Field> wf_Fields { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_FormInstance")]
    public partial class wf_FormInstance
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 TemplateFormId { get; set; }
        public String Name { get; set; } // character varying(50)(50)
        [NonUpdatable]
        public int State { get; set; }
        public int Version { get; set; }

        // wf_Field_FormId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FormId", CanBeNull = true)]
        public IEnumerable<wf_FieldInstance> wf_FieldInstances { get; set; }

        // wf_Flow_FormId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "FormId", CanBeNull = true)]
        public IEnumerable<wf_Flow> wf_Flows { get; set; }

        [Association(ThisKey = "TemplateFormId", OtherKey = "Id", CanBeNull = true)]
        public wf_Form wf_Form { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Node")]
    public partial class wf_Node
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 FlowId { get; set; } // integer
        public Int32 ActionId { get; set; } // integer
        public String Name { get; set; } // character varying(50)(50)
        [Nullable]
        public Int32? ToUser { get; set; } // integer
        [Nullable]
        public Int32? ToDept { get; set; } // integer
        [Nullable]
        public Int32? ToPosition { get; set; } // integer
        [Nullable]
        public Int32? ToRole { get; set; }
        [Nullable]
        public Boolean? InDept { get; set; }
        public String Argument { get; set; } // text
        [NonUpdatable]
        public Int32 State { get; set; }
        [Nullable]
        public Boolean AllowSkip { get; set; }


        // wf_Node_FlowId_fkey
        [Association(ThisKey = "FlowId", OtherKey = "Id", CanBeNull = false)]
        public wf_Flow wf_Flow { get; set; }

        // wf_Node_ToUser_fkey
        [Association(ThisKey = "ToUser", OtherKey = "Id", CanBeNull = true)]
        public sys_User sys_User { get; set; }

        // wf_Node_ToDept_fkey
        [Association(ThisKey = "ToDept", OtherKey = "Id", CanBeNull = true)]
        public sys_Org sys_Org { get; set; }

        // wf_Node_ToPosition_fkey
        [Association(ThisKey = "ToPosition", OtherKey = "Id", CanBeNull = true)]
        public sys_Position sys_Position { get; set; }

        // wf_NodeInstance_NodeId_fkey_BackReference
        [Association(ThisKey = "Id", OtherKey = "NodeId", CanBeNull = true)]
        public IEnumerable<wf_NodeInstance> wf_NodeInstances { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_NodeInstance")]
    public partial class wf_NodeInstance
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public String Name { get; set; }
        public Int32 FlowId { get; set; } // integer
        public Int32 NodeId { get; set; } // integer
        public Int32 FlowInstanceId { get; set; } // integer
        [Nullable]
        public Int32? FormId { get; set; } // integer
        [Nullable]
        public Int32? FormInstanceId { get; set; } // integer
        [Nullable]
        public Int32? CreateUserId { get; set; } // integer
        [Nullable]
        public Int32? WorkUserId { get; set; } // integer
        [NonUpdatable]
        public Int32 State { get; set; } // integer
        public String Result { get; set; } // text
        [NonUpdatable]
        public DateTime CreationTime { get; set; }
        [NonUpdatable]
        public DateTime UpdatedTime { get; set; }

        // wf_NodeInstance_FlowId_fkey
        [Association(ThisKey = "FlowId", OtherKey = "Id", CanBeNull = false)]
        public wf_Flow wf_Flow { get; set; }

        // wf_NodeInstance_NodeId_fkey
        [Association(ThisKey = "NodeId", OtherKey = "Id", CanBeNull = false)]
        public wf_Node wf_Node { get; set; }

        // wf_NodeInstance_FlowInstanceId_fkey
        [Association(ThisKey = "FlowInstanceId", OtherKey = "Id", CanBeNull = false)]
        public wf_FlowInstance wf_FlowInstance { get; set; }

        // wf_NodeInstance_CreateUserId_fkey
        [Association(ThisKey = "CreateUserId", OtherKey = "Id", CanBeNull = true)]
        public sys_User CreateUser { get; set; }

        // wf_NodeInstance_WorkUserId_fkey
        [Association(ThisKey = "WorkUserId", OtherKey = "Id", CanBeNull = true)]
        public sys_User WorkUser { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Transition")]
    public partial class wf_Transition
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; }

        public Int32 FlowId { get; set; } // integer
        public Int32 NodeId { get; set; } // integer
        [Nullable]
        public Int32? PreNodeId { get; set; } // integer
        [Nullable]
        public Int32? NextNodeId { get; set; } // integer
        public String Condition { get; set; } // text

        [Association(ThisKey = "FlowId", OtherKey = "Id", CanBeNull = false)]
        public wf_Flow wf_Flow { get; set; }

        [Association(ThisKey = "NodeId", OtherKey = "Id", CanBeNull = false)]
        public wf_Node wf_Node { get; set; }

        [Association(ThisKey = "PreNodeId", OtherKey = "Id", CanBeNull = true)]
        public wf_Node PreNode { get; set; }

        [Association(ThisKey = "NextNodeId", OtherKey = "Id", CanBeNull = true)]
        public wf_Node NextNode { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_RoleFlow")]
    public partial class wf_RoleFlow
    {
        [PrimaryKey(1)]
        public Int32 RoleId { get; set; }
        [PrimaryKey(2)]
        public Int32 FlowId { get; set; }

        [Association(ThisKey = "RoleId", OtherKey = "Id", CanBeNull = false)]
        public sys_Role sys_Role { get; set; }

        [Association(ThisKey = "FlowId", OtherKey = "Id", CanBeNull = false)]
        public wf_Flow wf_Flow { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Table")]
    public partial class wf_Table
    {
        [PrimaryKey, Identity]
        public Int32 Id { get; set; }
        [NonUpdatable]
        public Int32 State { get; set; }

        [Association(ThisKey = "Id", OtherKey = "TableId")]
        public IEnumerable<wf_Column> wf_Columns { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Column")]
    public partial class wf_Column
    {
        [Identity, PrimaryKey(1)]
        public Int32 Id { get; set; } // integer
        public Int32 TableId { get; set; } // integer
        public Int32 ControlId { get; set; } // integer
        public String ColumnName { get; set; } // character varying(50)(50)
        public Boolean Nullable { get; set; } // boolean
        public Int32 Source { get; set; } // integer
        [NonUpdatable]
        public Int32 State { get; set; }
        public String Argument { get; set; } // text
        public String DefaultValue { get; set; } // text

        // wf_Field_FormId_fkey
        [Association(ThisKey = "TableId", OtherKey = "Id", CanBeNull = false)]
        public wf_Table wf_Table { get; set; }

        // wf_Field_ControlId_fkey
        [Association(ThisKey = "ControlId", OtherKey = "Id", CanBeNull = false)]
        public wf_FieldControl wf_FieldControl { get; set; }
    }

    [TableName(Owner = "public", Name = "wf_Firewall")]
    public partial class wf_Firewall
    {
        [PrimaryKey(1)]
        public Int32 NodeId { get; set; }
        [PrimaryKey(2)]
        public Int32 CreateUserId { get; set; }

        public Int32 WorkUserId { get; set; }

        [Association(ThisKey = "NodeId", OtherKey = "Id", CanBeNull = false)]
        public wf_Node wf_Node { get; set; }

        [Association(ThisKey = "CreateUserId", OtherKey = "Id", CanBeNull = false)]
        public sys_User sys_User { get; set; }

        [Association(ThisKey = "WorkUserId", OtherKey = "Id", CanBeNull = false)]
        public sys_User sys_User2 { get; set; }
    }
}
